package com.mingyuan.library.domain.lending.patron.event;

import com.mingyuan.library.domain.lending.book.model.valueobject.BookId;
import com.mingyuan.library.domain.lending.librarybranch.model.valueobject.LibraryBranchId;
import com.mingyuan.library.domain.lending.patron.model.valueobject.PatronId;
import lombok.NonNull;
import lombok.Value;

import java.time.Instant;
import java.util.UUID;

/**
 * 图书预定取消
 */
@Value
public class BookHoldCanceled implements PatronEvent {
    @NonNull
    UUID eventId = UUID.randomUUID();
    @NonNull
    Instant when;
    @NonNull
    UUID patronId;
    @NonNull
    UUID bookId;
    @NonNull
    UUID libraryBranchId;

    /**
     * 取消当前预定
     *
     * @param bookId          图书ID
     * @param libraryBranchId 图书馆ID
     * @return
     * @author yangzk
     * @date 2023/12/28 23:12
     **/
    public static BookHoldCanceled holdCanceledNow(BookId bookId, LibraryBranchId libraryBranchId, PatronId patronId) {
        return new BookHoldCanceled(
                Instant.now(),
                patronId.getPatronId(),
                bookId.getBookId(),
                libraryBranchId.getLibraryBranchId());
    }
}